<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>更换背景</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">

		<link rel="stylesheet" href="${pageContext.request.contextPath }/layui/css/layui.css">
		<script src="${pageContext.request.contextPath }/layui/layui.js"></script>

		<script language="javascript" src="/js/check_updatePwd.js"></script>
		<SCRIPT language=JavaScript src="/js/pinbi.js"></SCRIPT>

	</head>

	<body>
		<fieldset class="layui-elem-field">
			<legend>更换背景</legend>
			<div class="layui-field-box"></div>
		</fieldset>
		<form method="post" action="/genghuan1" enctype="multipart/form-data">
			<div class="layui-upload">
				<button type="button" class="layui-btn" id="test1">上传图片</button>
				<div class="layui-upload-list">
					<img class="layui-upload-img" id="demo1">
					<p id="demoText"></p>
				</div>
			</div>
			<input name="submit" type="submit" class="layui-btn layui-btn-primary" id="submit" value="提交">
		</form>

		<script>

			layui.use(['upload','element','layer'], function() {
				var $ = layui.jquery;
				var element = layui.element;
				var layer = layui.layer;
				var upload = layui.upload;

				//普通图片上传
				var uploadInst = upload
					.render({
						elem: '#test1',
						url: '/genghuan1' //改成您自己的上传接口
							,
						before: function(obj) {
							//预读本地文件示例，不支持ie8
							obj.preview(function(index,
								file, result) {
								$('#demo1').attr('src',
									result); //图片链接（base64）
							});
						},
						done: function(res) {
							//如果上传失败
							if (res.code > 0) {
								return layer.msg('上传失败');
							}
							//上传成功
						},
						error: function() {
							//演示失败状态，并实现重传
							var demoText = $('#demoText');
							demoText
								.html(
									'<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>'
								);
							demoText.find('.demo-reload').on(
								'click',
								function() {
									uploadInst.upload();
								});
						}
					});
				
			});

		</script>

	</body>
</html>
